package com.quanshi.shopping_search_customer_api.controller;


import com.quanshi.shopping_common.entity.Goods;
import com.quanshi.shopping_common.entity.GoodsDesc;
import com.quanshi.shopping_common.entity.GoodsSearchParam;
import com.quanshi.shopping_common.entity.GoodsSearchResult;
import com.quanshi.shopping_common.result.BaseResult;
import com.quanshi.shopping_common.service.IGoodsDescService;
import com.quanshi.shopping_common.service.IGoodsService;
import com.quanshi.shopping_common.service.ISearchService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/goodsSearch")
public class SearchController {

    @DubboReference
    private ISearchService searchService;


    @DubboReference
    private IGoodsDescService  goodsDescService;


    @GetMapping("/autoSuggest")
    public BaseResult autoSuggest(String keyword){
        return BaseResult.success(searchService.autoSuggest(keyword));
    }


    @PostMapping("/search")
    public BaseResult search(@RequestBody GoodsSearchParam goodsSearchParam){
        GoodsSearchResult result = searchService.search(goodsSearchParam);
        return BaseResult.success(result);
    }

    @GetMapping("/findDesc")
    public BaseResult findDesc(Long id){
        GoodsDesc goodsDesc = goodsDescService.findDesc(id);
        return BaseResult.success(goodsDesc);
    }

}
